package com.james.controller;

import com.james.domain.Menu;
import com.james.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: MenuController
 * @Author: JamesWang
 * @Date: 2021/4/22 12:39
 * @Description:
 * @Version:1.0
 */
@RestController
@RequestMapping("menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @GetMapping("loadMenuTree")
    public ResponseEntity<Map<String,Object>> loadMenuTree() {

        List<Menu> menuTree = menuService.getMenuTree();

        Map<String, Object> map = new HashMap<>(8);
        map.put("code",200);
        map.put("msg","ok");
        map.put("data",menuTree);
        return ResponseEntity.ok(map);
    }

}
